<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
</head>
<body>
<div id="app">
    <h1>我的微博列表</h1>
    <div v-for="w in arr">
        <h3>{{w.content}}</h3>
        <p>发布于:{{w.created}}<a href="javascipt:void(0)" @click="del(w.id)">删除</a></p>
    </div>
</div>
</body>
<!-- import Vue before Element -->
<!--引入axios和vue-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.14/vue.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: function() {
            return {
               arr:[]
            }
        },
        methods:{
            del(id){
                if(confirm("确定删除此微博吗?")){
                    axios.get("/weibo/delete?id="+id).then(function () {
                        location.reload();
                    })
                }
            }
        },
        created:function () {
            axios.get("/weibo/select/mine").then(function (response) {
                console.log(response.data);
                console.log(response.data.code);
                if(response.data.code==2){
                    alert("请先登录");
                    location.href="/login.html";
                }else {
                    v.arr = response.data.data;;
                }
            })
        }
    })
</script>
</html>